package demo1;

class Base {
    public int a;
    public int b;
}

class Derived extends Base {
    public int c;

    public void method() {
        a = 1;
        b = 2;
        c = 3;
    }
}


class Base1 {
    public int a = 9;
    public int b = 99;
}

class Derived1 extends Base1 {
    public int a = 88;

    public void method() {
        System.out.println("a:" + a);
        System.out.println("b:" + b);

    }
}

public class Test2 {
    public static void main(String[] args) {
        Derived1 d1 = new Derived1();
        d1.method();// 访问成员变量的准则： 就近原则  同时 方法的原则也是一样的
    }

    public static void main1(String[] args) {
        Derived d = new Derived();
        System.out.println(d.a);
        System.out.println(d.b); // a 和 b是从父类继承下来的 子类和父类中的成员变量不存在同名
        System.out.println(d.c);
    }
}
